﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _12_OtherOperationsWithPolynomes
{
    class Program
    {
        static int[] Input(out int pow, int number)
        {
            Console.Write("Enter the heighest power of x for polynome {0}: ", number);
            int power = int.Parse(Console.ReadLine());
            int[] polynome = new int[power + 1];
            for (int index = 0; index <= power; index++)
            {
                polynome[power - index] = int.Parse(Console.ReadLine());
            }
            pow = power;
            return polynome;
        }

        static int[] SumOfPolynoms(int[] firstPolinome, int[] secondPolinome)
        {
            int[] result = new int[Math.Max(firstPolinome.Length, secondPolinome.Length)];
            int index;
            for (index = 0; index < Math.Min(firstPolinome.Length, secondPolinome.Length); index++)
            {
                result[index] = firstPolinome[index] + secondPolinome[index];
            }
            for (; index < Math.Max(firstPolinome.Length, secondPolinome.Length); index++)
            {
                result[index] = firstPolinome.Length > secondPolinome.Length ? firstPolinome[index] : secondPolinome[index];
            }

            return result;
        }

        static int[] SubstractionOfPolynoms(int[] firstPolinome, int[] secondPolinome)
        {
            int[] result = new int[Math.Max(firstPolinome.Length, secondPolinome.Length)];
            int index;
            for (index = 0; index < Math.Min(firstPolinome.Length, secondPolinome.Length); index++)
            {
                result[index] = firstPolinome[index] - secondPolinome[index];
            }
            for (; index < Math.Max(firstPolinome.Length, secondPolinome.Length); index++)
            {
                result[index] = firstPolinome.Length > secondPolinome.Length ? firstPolinome[index] : -secondPolinome[index];
            }

            return result;
        }

        static int[] MultiplicationOfPolynomes(int[] firstPolinome, int[] secondPolinome)
        {
            int[] result = new int[firstPolinome.Length + secondPolinome.Length];
            for (int i = 0; i < result.Length; i++)
            {
                for (int j = 0; j < firstPolinome.Length; j++)
                {
                    for (int k = 0; k < secondPolinome.Length; k++)
                    {
                        if (k + j == i)
                        {
                            result[i] += firstPolinome[j] * secondPolinome[k];
                        }
                    }
                }
            }
            return result;
        }

        static void Print(int[] arr)
        {
            for (int index = arr.Length - 1; index >= 0; index--)
            {
                Console.Write("{0}x^{1} ", arr[index], index);
            }
        }

        static void Main(string[] args)
        {


        }
    }
}